﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DAO
{
    public class DAO_KHOAHOC
    {
        QLTTTHDataContext QLTTTH = new QLTTTHDataContext();
        public List<LOPHOC> Latthongtinkhoahoc()
        {
            return QLTTTH.LOPHOCs.ToList();
        }
        public bool  ThemLopMoi(LOAILOP lop)
        {
            try
            {
                QLTTTH.LOAILOPs.InsertOnSubmit(lop);
                QLTTTH.SubmitChanges();
                return true;
            }
            catch
            {
                return false;
            }
        }
        public List<LOAILOP> LayThongTinLoaiLop()
        {
            return QLTTTH.LOAILOPs.ToList();
        }
        public bool CapNhatLop(LOAILOP lop)
        {
            try
            {
                var loailop = (from tv in QLTTTH.LOAILOPs
                               where tv.TENLOP == lop.TENLOP
                               select tv).SingleOrDefault();
                loailop.TENLOP = lop.TENLOP;
                QLTTTH.SubmitChanges();
                return true;
            }
            catch
            {
                return false;
            }
        }
    }
}
